jQuery(document).ready(function() {
	// select和input焦点问题
	$('.select-contain').mouseover(function() {
		$('.search-select').blur();
	});
	// 顶部页签点击事件
	$("#iframe-nav ul li").on("click", function() {
		changeIframeNav($(this));
	})
	
	// 设置查询条件的显示/隐藏
	var flag = 0;
	$('#setSearchOnShow').on("click", function() {
		if (flag == 0) {
			$('#searchContent').css('display', 'none'); //隐藏
			$('#searchFooter').css('display', 'none'); //隐藏
			$('.set-text').text('显示搜索条件');
			flag = 1;
		} else {
			$('#searchContent').css('display', 'block'); //显示
			$('#searchFooter').css('display', 'flex'); //显示
			$('.set-text').text('隐藏搜索条件');
			flag = 0;
		}
	})
	
	// 表头数据
	var tableHeader = [{
			columnWidth: 30,
			columnKey: 'check',
			columnName: ''
		},
		{
			columnWidth: 30,
			columnKey: 'id',
			columnName: '序号'
		},
		{
			columnWidth: 150,
			columnKey: 'number',
			columnName: '客户号码'
		},
		{
			columnWidth: 60,
			columnKey: 'name',
			columnName: '客户名称'
		},
		{
			columnWidth: 60,
			columnKey: 'type',
			columnName: '客户类型'
		},
		{
			columnWidth: 70,
			columnKey: 'tel',
			columnName: '电话'
		},
		{
			columnWidth: 600,
			columnKey: 'phone',
			columnName: '手机'
		},
		{
			columnWidth: 90,
			columnKey: 'province',
			columnName: '省份'
		},
		{
			columnWidth: 60,
			columnKey: 'city',
			columnName: '城市'
		},
		{
			columnWidth: 80,
			columnKey: 'county',
			columnName: '区(县)'
		},
		{
			columnWidth: 60,
			columnKey: 'address',
			columnName: '地址'
		},
		{
			columnWidth: 30,
			columnKey: 'postcode',
			columnName: '邮编'
		},
		{
			columnWidth: 70,
			columnKey: 'email',
			columnName: '电子邮件'
		},
		{
			columnWidth: 70,
			columnKey: 'carSeries',
			columnName: '车系'
		},
		{
			columnWidth: 70,
			columnKey: 'carType',
			columnName: '车型'
		},
		{
			columnWidth: 70,
			columnKey: 'vin',
			columnName: 'VIN'
		},
		{
			columnWidth: 70,
			columnKey: 'brandModel',
			columnName: '厂牌型号'
		},
		{
			columnWidth: 70,
			columnKey: 'price',
			columnName: '价格'
		},
		{
			columnWidth: 70,
			columnKey: 'payMethod',
			columnName: '付款方式'
		},
		{
			columnWidth: 70,
			columnKey: 'sitCount',
			columnName: '座位数'
		},
	]

	// 表格数据
	var dataList = [{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
		{
			check: false,
			id: '001',
			number: 13866666666,
			name: '张三',
			type: '学生',
			tel: '83659999',
			phone: '13866666666',
			province: '辽宁省',
			city: '大连市',
			county: '高新',
			address: '你猜猜',
			postcode: '116110',
			email: 'aaaa',
			carSeries: '格瑞斯',
			carType: '不知道',
			vin: 'NMNK4564654',
			brandModel: '学生',
			price: '16666666',
			payMethod: '一次性',
			sitCount: '3',
		},
	];

	// 渲染表格头部
	for (var i = 0; i < tableHeader.length; i++) {
		$('#tbHeaderCol').append('<col style= width:' + tableHeader[i].columnWidth + 'px></col>');
		$('#tbBodyCol').append('<col style= width:' + tableHeader[i].columnWidth + 'px></col>');
	}

	// 渲染表格数据
	for (var i = 0; i < dataList.length; i++) {
		var row = document.createElement('tr');
		var trow = getDataRow(row, dataList[i], i);
		$('#tbBody').append(trow);
	}

	//获取数据
	function getDataRow(item, h, index) {
		for (var i = 0; i < tableHeader.length; i++) {
			var val = tableHeader[i];
			var itemCell = document.createElement('td');
			var itemCellSpan = document.createElement('span');
			if (val.columnKey == 'check') {
				itemCellSpan.innerHTML =
					'<div class="mui-input-row mui-checkbox "><input name="Checkbox" type="checkbox"></div>';
			} else if (val.columnKey == 'number') {
				itemCellSpan.innerHTML = '<div style="color: #94252A;text-decoration-line: underline;">' + h[val
						.columnKey] +
					'</div>';
			} else {
				itemCellSpan.innerText = h[val.columnKey];
			}
			itemCell.appendChild(itemCellSpan);
			item.appendChild(itemCell);
		}
		return item;
	}
});
